﻿using System.Collections.Generic;
using FoundationClass.Data;
using FoundationClass.Entity;

namespace FoundationClass
{
   public  static class MasterDataHandler
    {
       public static IList<Promotion> GetAllPromotions()
       {
           return PromotionData.GetAllPromotions();
       }
       public static IList<Computer> GetAllComputors()
       {
           return ComputerData.GetAllComputers();
       }
       public static IList<Computer> GetAllComputorsActive()
       {
           return ComputerData.GetAllComputersActive();
       }

       public static void AddPromotion(Promotion promotion)
       {
           PromotionData.InsertPromotion(promotion);
       }
       public static void UpdatePromotion(Promotion promotion)
       {
          PromotionData.UpdatePromotion(promotion);
       }
       public static Promotion GetPromotion(int id)
       {
           return PromotionData.GetPromotion(id);
       }
       public static void RemovePromotion(int id)
       {
           PromotionData.DeletePromotion(id);
       }

       public static void UpdateComputer(Computer computer)
       {
          ComputerData.UpdateComputer(computer);
       }

       public static IList< Payment> ListPayments()
       {
           return PaymentData.GetAllPayments();
       }

       public static void AddComputer(Computer computer)
       {
           ComputerData.InsertComputer(computer);
       }
       public static void RemoveComputer(int id)
       {
           ComputerData.DeleteComputer(id);
       }
       public static Computer GetComputer(int id)
       {
           return ComputerData.GetComputer(id);
       }

       public static IList<Computer> ListUnusedComputer()
       {
           IList<Computer> computers = GetAllComputorsActive();
           IList<Computer> unusedcomputers = new List<Computer>();
           foreach (var computer in computers)
           {
               unusedcomputers.Add(computer);
           }
           IList<ServiceRecord> serviceRecords = GetAllServiceRecords();

           foreach (var com in computers)
           {
               foreach (var serviceRecord in serviceRecords)
               {
                   if (com.Id.Equals(serviceRecord.Computer.Id)) unusedcomputers.Remove(com);
               }
           }
           return unusedcomputers;
       }
       public static ServiceRecord GetServiceRecord(int id)
       {
           return ServiceRecordData.GetServiceRecord(id);
       }

       public static IList<ServiceRecord> GetAllServiceRecords()
       {
           return ServiceRecordData.GetServiceRecords();
       }

       public static IList<ServiceRecord> GetAllServiceRecordsAvaliable()
       {
           return ServiceRecordData.GetServiceRecordsAvaliable();
       }

       public static IList<ServiceRecord> GetAllServiceRecordsPaid()
       {
           return ServiceRecordData.GetServiceRecordsPaid();
       }

       public static IList<ServiceRecord> GetAllServiceRecordsClose()
       {
           return ServiceRecordData.GetServiceRecordsClose();
       }

       public static void AddSevicesRecord(ServiceRecord record)
       {
           ServiceRecordData.InsertServiceRecord(record);
       }

       public static void UpdateSevicesRecord(ServiceRecord record)
       {
           ServiceRecordData.UpdateServiceRecord(record);
       }

       public static void UpdateStatusComputer(int id, char status)
       {
           ComputerData.UpdateStatusComputer(id, status);
       }

       public static void DeleteSevicesRecord(int id)
       {
           ServiceRecordData.DeleteServiceRecord(id);
       }
    }
}
